﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using Outlook = Microsoft.Office.Interop.Outlook;
using Office = Microsoft.Office.Core;
using Microsoft.Office.Tools;

namespace WunderList
{
	public partial class ThisAddIn
	{
		private WunderLookPanel wlPanel;
		private CustomTaskPane panelValue;

		/// <summary>
		/// Gets the panel value.
		/// </summary>
		public CustomTaskPane PanelValue
		{
			get { return this.panelValue; }
		}

		/// <summary>
		/// Handles the Startup event of the ThisAddIn control.
		/// </summary>
		/// <param name="sender">The source of the event.</param>
		/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
		private void ThisAddIn_Startup(object sender, System.EventArgs e)
		{
			// initialize panel and add to outlook
			wlPanel = new WunderLookPanel();
			panelValue = this.CustomTaskPanes.Add(wlPanel, "WunderLook");

			// handle change in panel state
			wlPanel.VisibleChanged += new EventHandler(wlPanel_VisibleChanged);
		}

		/// <summary>
		/// Handles the VisibleChanged event of the wlPanel control.
		/// </summary>
		/// <param name="sender">The source of the event.</param>
		/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
		private void wlPanel_VisibleChanged(object sender, EventArgs e)
		{
			// update UI for pane visibility status
			// This feels backwards (UI should update the status, not vice versa) but that's how the example did it so here it is.
			Globals.Ribbons.WunderLookRibbon.wlPanelButton.Checked = panelValue.Visible;
		}

		private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
		{

		}

		#region VSTO generated code

		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InternalStartup()
		{
			this.Startup += new System.EventHandler(ThisAddIn_Startup);
			this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
		}
		
		#endregion
	}
}
